/*******************************************************************************
 * Copyright 2011-2012 Dik Grapendaal
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package sh.grapendaal.tsuushin.tracking;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import sh.grapendaal.tsuushin.message.User;

/**
 * Class representing a user on an IRC server.
 */
public final class TrackedUser extends User {
	private String networkName;
	private String realname;

	/**
	 * This class can only be instantiated from the factory method parse().
	 */
	public TrackedUser(String nickname) {
		this(nickname, null, null);
	}

	/**
	 * This class can only be instantiated from the factory method parse().
	 */
	public TrackedUser(String nickname, String username, String hostname) {
		super(nickname, username, hostname);
	}

	public String getNetworkName() {
		return networkName;
	}

	public void setNetworkName(String networkName) {
		this.networkName = networkName;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	@Override
	public boolean equals(Object object) {
		if (!(object instanceof TrackedUser)) {
			return false;
		}
		if (this == object) {
			return true;
		}
		TrackedUser rhs = (TrackedUser) object;
		return new EqualsBuilder().appendSuper(super.equals(object)).append(this.networkName, rhs.networkName)
				.append(this.realname, rhs.realname).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().appendSuper(super.hashCode()).append(this.networkName).append(this.realname)
				.toHashCode();
	}
	
	@Override
	public String toString() {
		return new ToStringBuilder(this).appendSuper(super.toString()).append(this.networkName).append(this.realname)
				.toString();
	}
}
